#pragma once

#include "Resource.h"

#include "ExtraData\IExtraResourceData.h"

class ResourceCache;

class ResourceHandle
{
	friend class ResourceCache;

	protected:
		Resource _resource;
		char *_pBuffer;	
		unsigned int _size;
		shared_ptr<IExtraResourceData> _extra;
		ResourceCache *_pResourceCache;

	public:
		
		ResourceHandle(
			Resource& resource, 
			char* pBuffer, 
			unsigned int size, 
			ResourceCache* pResourceCache);

		virtual ~ResourceHandle();

		const std::string GetName() { return _resource.Name; }
		
		unsigned int Size() const { return _size; } 
		
		char* Buffer() const { return _pBuffer; }
		
		char* WritableBuffer() { return _pBuffer; }

		shared_ptr<IExtraResourceData> GetExtra() { return _extra; }

		void SetExtra(shared_ptr<IExtraResourceData> extra) { _extra = extra; }
};